<%@ Page Language="C#" MasterPageFile="~/Administration/main.master" AutoEventWireup="true"
    CodeFile="Currencies.aspx.cs" Inherits="Tathata.Web.Administration.Administration_Currencies" %>

<%@ Register TagPrefix="nopCommerce" TagName="DecimalTextBox" Src="Modules/DecimalTextBox.ascx" %>
<asp:Content ID="c1" ContentPlaceHolderID="cph1" runat="Server">
    <h4>
        Currencies</h4>
    <asp:UpdatePanel ID="UpdatePanelCurrencies" runat="server">
        <ContentTemplate>
            <asp:GridView ID="gvCurrencies" runat="server" AutoGenerateColumns="False" Width="100%">
                <Columns>
                    <asp:BoundField DataField="CurrencyID" HeaderText="CurrencyID" Visible="False"></asp:BoundField>
                    <asp:TemplateField HeaderText="Name" ItemStyle-Width="20%">
                        <ItemTemplate>
                            <a href="CurrencyDetails.aspx?CurrencyID=<%#Eval("CurrencyID")%>">
                                <%#Server.HtmlEncode(Eval("Name").ToString())%>
                            </a>
                            <asp:HiddenField runat="server" ID="hfCurrencyID" Value='<%#Eval("CurrencyID")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CurrencyCode" HeaderText="Currency code" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="7%" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                    <asp:BoundField DataField="DisplayLocale" HeaderText="Display locale" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="7%" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                    <asp:BoundField DataField="Rate" HeaderText="Rate" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="7%" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                    <asp:BoundField DataField="Published" HeaderText="Published" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="7%" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                    <asp:BoundField DataField="DisplayOrder" HeaderText="Display order" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="7%" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                    <asp:TemplateField HeaderText="Primary exchange rate currency" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="14%" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:RadioButton runat="server" ID="rdbIsPrimaryExchangeRateCurrency" Checked='<%#Eval("IsPrimaryExchangeRateCurrency")%>'
                                OnCheckedChanged="rdbIsPrimaryExchangeRateCurrency_CheckedChanged" AutoPostBack="true" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Primary store currency" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="14%" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:RadioButton runat="server" ID="rdbIsPrimaryStoreCurrency" Checked='<%#Eval("IsPrimaryStoreCurrency")%>'
                                OnCheckedChanged="rdbIsPrimaryStoreCurrency_CheckedChanged" AutoPostBack="true" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="7%"
                        ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <a href="CurrencyDetails.aspx?CurrencyID=<%#Eval("CurrencyID")%>">Edit</a>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="up1" runat="server">
        <ProgressTemplate>
            <div class="progress">
                <asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/UpdateProgress.gif" />
                Updating .....
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <br>
    <input type="button" onclick="location.href='CurrencyAdd.aspx'" value="Add new" id="btnAddNew"
        class="adminButton" />
    <br />
    <br />
    <h4>
        Live currency rates</h4>
    <table width="100%">
        <tr>
            <td colspan="2">
                <asp:GridView ID="gvLiveRates" runat="server" AutoGenerateColumns="False" Width="400px"
                    OnRowCommand="gvLiveRates_RowCommand" OnRowDataBound="gvLiveRates_RowDataBound">
                    <Columns>
                        <asp:TemplateField HeaderText="Currency code" HeaderStyle-HorizontalAlign="Center"
                            ItemStyle-Width="200px" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblCurrencyCode" Text='<%# Eval("CurrencyCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Rate" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px"
                            ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <nopCommerce:DecimalTextBox runat="server" CssClass="adminInput" Width="50px" Value='<%# Eval("Rate") %>'
                                    ID="txtRate" RequiredErrorMessage="Rate is required" MinimumValue="0" MaximumValue="99999"
                                    ValidationGroup="ApplyLiveRateGrid" RangeErrorMessage="The value must be from 0 to 99999">
                                </nopCommerce:DecimalTextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Apply rate" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px"
                            ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Button ID="btnApplyRate" runat="server" CssClass="adminButton" Text="Apply rate"
                                    ValidationGroup="ApplyLiveRateGrid" CommandName="ApplyLiveRate" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button runat="server" Text="Get live rates" CssClass="adminButton" ID="btnGetLiveRates"
                    ValidationGroup="GetLiveRates" OnClick="btnGetLiveRates_Click"></asp:Button>
            </td>
        </tr>
    </table>
</asp:Content>
